package com.mathlearning.auth.repository;

import com.mathlearning.auth.entity.DiscussionFavorite;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface DiscussionFavoriteRepository extends JpaRepository<DiscussionFavorite, Long> {
    
    // 查找用户对某个讨论的收藏记录
    Optional<DiscussionFavorite> findByDiscussionIdAndUserId(Long discussionId, Long userId);
    
    // 判断用户是否收藏了某个讨论
    boolean existsByDiscussionIdAndUserId(Long discussionId, Long userId);
    
    // 获取用户收藏的所有讨论ID
    List<DiscussionFavorite> findByUserId(Long userId);
    
    // 删除用户对某个讨论的收藏
    void deleteByDiscussionIdAndUserId(Long discussionId, Long userId);
}








